#include <iostream>
#include <string>
#include <fstream>
#include "bundle.h"


using namespace std;


int main(int argc, char* argv[])
{
    if (argc < 3) {
        cerr << "Usage: " << argv[0] << " <input_file> <output_file>" << endl;
        return 1;
    }

    string ifilename = argv[1];
    string ofilename = argv[2];

    ifstream ifs;
    ifs.open(ifilename,ios::binary);

    ifs.seekg(0,ios::end);
    size_t fszie = ifs.tellg();
    ifs.seekg(0,ios::beg);

    string body;
    body.resize(fszie);
    ifs.read(&body[0],fszie);

    string unpacked = bundle::unpack(body);

    ofstream ofs;
    ofs.open(ofilename,ios::binary);
    ofs.write(&unpacked[0],unpacked.size());


    ofs.close();
    ifs.close();


    return 0;
}